#include<cstdio>
#include<iostream>
using namespace std;

int t1 = 1,t2 = 1,num[1000001];

int main(){
	int a,b;
	while(cin>>a){
		cin>>b;
		num[1] = a;
		for(int i=1;i<=b;i++){
			if(2*num[t1]+1 < 3*num[t2]+1){
				num[i+1] = 2*num[t1++]+1;
				if(t1 == b or t2 ==b)	break;
			}else if(2*num[t1]+1 > 3*num[t2]+1){
				num[i+1] = 3*num[t2++]+1;
				if(t1 == b or t2 ==b)	break;
			}else if(2*num[t1]+1 == 3*num[t2]+1){
				num[i+1] = 3*num[t2++]+1;
				t1++;
				if(t1 == b or t2 ==b)	break;
			}
		}
		cout<<num[b]<<endl;
		t1=1;t2=1;
	}
	return 0;
}
